﻿namespace OffLineVoice
{
    public class KeyWordBuilder
    {
        private readonly Dictionary<string, ISpeakData> keyWords;
        public KeyWordBuilder()
        {
            keyWords = new();
        }

        public Dictionary<string, ISpeakData> KeyWordCollection => keyWords;

        /// <summary>
        /// 添加操作路径
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddOperatePath()
        {
            keyWords.Add("前进", new OperatePathData(0));
            keyWords.Add("后退", new OperatePathData(1));
            return this;
        }

        /// <summary>
        /// 添加牙齿选择
        /// </summary>
        public KeyWordBuilder AddToothSelection()
        {
            var list = new List<int>();
            list.AddRange(Enumerable.Range(11, 8));
            list.AddRange(Enumerable.Range(21, 8));
            list.AddRange(Enumerable.Range(31, 8));
            list.AddRange(Enumerable.Range(41, 8));
            foreach (int item in list)
            {
                keyWords.Add($"牙位{item}唇侧", new ToothSelectionData(item, true));
            }
            foreach (int item in list)
            {
                keyWords.Add($"牙位{item}腭侧", new ToothSelectionData(item, false));
            }
            return this;
        }

        /// <summary>
        /// 添加牙位选择
        /// </summary>
        public KeyWordBuilder AddDentalPositionSelection()
        {
            keyWords.Add($"近中", new DentalPositionSelectionData(0));
            keyWords.Add($"正中", new DentalPositionSelectionData(1));
            keyWords.Add($"远中", new DentalPositionSelectionData(2));
            return this;
        }

        /// <summary>
        /// 添加牙齿类型
        /// </summary>
        public KeyWordBuilder AddToothType()
        {
            var arr = new string[] { "桥基牙", "桥基牙种植", "桥义齿", "乳牙", "牙冠", "龋齿", "阻生齿", "种植体", "缺失牙", "恒牙" };
            for (int i = 0; i < arr.Length; i++)
            {
                keyWords.Add($"{arr[i]}", new ToothTypeData(i + 1));
            }
            return this;
        }

        /// <summary>
        /// 添加袋深
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddPocketDepth()
        {
            foreach (int item in Enumerable.Range(0, 14))
            {
                keyWords.Add($"袋深{item}", new PocketDepthData(item));
            }
            return this;
        }

        /// <summary>
        /// 添加退缩/增生
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddShrinkageProliferation()
        {
            foreach (int item in Enumerable.Range(0, 5))
            {
                keyWords.Add($"退缩{item}", new ShrinkageProliferationData(0, item));
            }
            foreach (int item in Enumerable.Range(1, 5))
            {
                keyWords.Add($"增生{item}", new ShrinkageProliferationData(1, item));
            }
            return this;
        }

        /// <summary>
        /// 添加分叉
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddBifurcation()
        {
            foreach (int item in Enumerable.Range(0, 5))
            {
                keyWords.Add($"分叉{item}", new BifurcationData(item));
            }
            return this;
        }

        /// <summary>
        /// 添加松动度
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddLooseness()
        {
            foreach (int item in Enumerable.Range(0, 5))
            {
                keyWords.Add($"{item}级松动度", new LoosenessData(item));
            }
            return this;
        }

        /// <summary>
        /// 添加症状
        /// </summary>
        /// <param name="arr"></param>
        /// <returns></returns>
        public KeyWordBuilder AddSymptom()
        {
            var arr = new string[] { "菌斑", "出血", "化脓", "出血化脓" };
            for (int i = 0; i < arr.Length; i++)
            {
                keyWords.Add($"{arr[i]}", new SymptomData(i + 1));
            }
            return this;
        }

        public KeyWordBuilder Builder()
        {
            return this;
        }
    }
}
